<?php
/**
 * polwebgis
 * 
 * This file is part of polwebgis.
 *
 * @copyright   Copyright (c) 2012 Dominik Janisch (http://www.joanneum.at)
 * @lastmodified    $LastChangedDate: 2012-03-07 09:15:12 +0000 (Wed, 07 Mar 2012) $
 * @revision    $Revision: 160 $ 
 */

class TagsGateway extends TableDataGateway
{           
        
    public function __construct()
    {
        $this->establishConnection();
    }
        
    public function __destruct(){}
    
    public function getTagNameById($tag_id)
    {
        $stmt = $this->database_connection_->newStatement('SELECT tag_name FROM tags where tag_id=:tag_id');
        $stmt->bindValue(':tag_id', $tag_id, PDO::PARAM_INT);
        $stmt->execute();
        while($row = $stmt->fetch(PDO::FETCH_ASSOC))
            return $row['tag_name'];
        return false;
    }
    
    public function getTagsByParentId($parent_id)
    {
        $stmt = $this->database_connection_->newStatement('SELECT tag_id, tag_name FROM tags where tag_parent_id=:tag_parent_id order by tag_name');
        $stmt->bindValue(':tag_parent_id', $parent_id, PDO::PARAM_INT);
        $stmt->execute();
        $arr_return = array();
        while($row = $stmt->fetch(PDO::FETCH_ASSOC))
            $arr_return[] = $row;
        return $arr_return;
    }
}

?>
